<?php

require_once '../../config.php';
//服务端处理头像请求

//1.接受传递过来的邮箱
if (empty($_GET['email'])){
    exit('<h1>缺少必要的参数</h1>');
}

$email = $_GET['email'];

//2.连接数据库
$data = mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
if (!$data){
    exit('<h1>连接数据库失败</h1>');
}

//3.查询头像数据
$avatar = mysqli_query($data,"select avatar from users where email = '{$email}' limit 1" );
if (!$avatar){
    exit('<h1>查询失败</h1>');
}

//4.获取头像数据
$item_avatar = mysqli_fetch_assoc($avatar);
echo $item_avatar['avatar'];


